package com.exam.service.uploadfile.impl;

import java.util.List;

import javax.persistence.Query;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.exam.service.uploadfile.UploadFileService;
import com.exam.service.base.DaoSupport;

@Service
@Transactional
public class UploadFileServiceBean extends DaoSupport implements UploadFileService {

	@SuppressWarnings("unchecked")
	public List<String> getFilepath(Integer[] ids) {

		if(ids!=null&&ids.length>0){
			StringBuffer jpql=new StringBuffer("");
			int i=0;
			for(;i<ids.length-1;i++){
				jpql.append("?").append(i+1).append(",");
			}
			jpql.append("?").append(i+1);
			Query query=em.createQuery("select o.filePath from UploadFile o where o.id in("
					+jpql.toString()+")");
			for(i=0;i<ids.length;i++){
				query.setParameter(i+1, ids[i]);
			}
			return query.getResultList();
		}
		return null;
	}

	
}
